home *** CD-ROM | disk | FTP | other *** search
File List | 1994-03-01 | 596 b | 38 lines |
- #include <stdlib.h>
-
- class A
- {
- private:
- struct DataType
- {
- double x, y;
- } *data;
- int size;
- public:
- A();
- A(int n, double *x, double *y);
- sort();
- }
-
- A::A() { } // Code Omitted
-
- A::A(int n, double *x, double *y) { } // Code Omitted
-
-
- A::sort()
- {
- qsort(data, size, sizeof(DataType), compare_function);
- }
-
- int compare_function(const void *a, const void *b)
- {
- const DataType *first = (DataType *) a;
- const DataType *second = (DataType *) b;
- if ( first->x > second->x )
- return -1;
- else if ( first->x < second->x )
- return 1;
- else
- return 0;
- }
-